﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using XNAGameFeatures.BasicGame;
using XNAGameFeatures.Input;
using XNAGameFeatures.Input.Device;

namespace XNAGameFeatures.Widget
{
    public abstract class Button : Widget
    {
        public delegate void ButtonCallBack();
        protected Rectangle Area;

        public ButtonCallBack CallBack { get; set; }
        
        public override void HandleInput(InputManager input)
        {
            if (Area.Contains((int) input.MouseInput.MousePosition.X, (int) input.MouseInput.MousePosition.Y))
            {
                if (CallBack != null && input.MouseInput.IsButtonPressOnce(MouseButton.Left))
                    CallBack();
            }
        }
    }
}
